﻿using J.Model;
using J.ProductGet.Application.Command.ProductCommand;
using MediatR;
using SqlSugar;

namespace J.ProductGet.Application.CommandHandler.ProductCommandHandler
{
    public class ProductBackilCommandHandler : IRequestHandler<ProductBackilCommand, List<Product>>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public ProductBackilCommandHandler(ISqlSugarClient sqlSugarClient)
        {
            _sqlSugarClient = sqlSugarClient;
        }
        public async Task<List<Product>> Handle(ProductBackilCommand request, CancellationToken cancellationToken)
        {
             var list =  await _sqlSugarClient.Queryable<Product>().Where(s => s.ProductID == request.ProductID).ToListAsync();
            return list;
            //var lists = await _sqlSugarClient.Queryable<Product>().Where(it => it.ProductID == request.ProductID).ToListAsync();
        }
    }
}
